<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/logo.svg" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>DeepSeek</title>
    <style>
      body {
        height: var(--app-body-height, 100vh); /* 添加回退值 */
        margin: 0; /* 清除默认边距 */
      }
    </style>
  </head>
  <body>
    <div id="root"></div>
    <script type="module" src="/src/main.tsx"></script>
    <script type="module">
      // 使用防抖函数优化性能
      const debounce = (fn, delay = 100) => {
        let timer;
        return (...args) => {
          clearTimeout(timer);
          timer = setTimeout(() => fn.apply(this, args), delay);
        };
      };

      const updateBodyHeight = () => {
        const height =
          window.innerHeight || document.documentElement.clientHeight;
        document.body.style.setProperty("--app-body-height", `${height}px`);
      };

      // 立即设置初始高度
      updateBodyHeight();

      // 使用防抖后的处理函数
      const debouncedHandler = debounce(updateBodyHeight);

      // 正确的事件监听对象
      window.addEventListener("resize", debouncedHandler);

      // 添加清理事件监听的逻辑
      window.addEventListener("beforeunload", () => {
        window.removeEventListener("resize", debouncedHandler);
      });
    </script>
  </body>
</html>
